package com.demomaster.quick_reader.model.novel;

import android.util.Log;

import com.demomaster.quick_reader.model.novel.Void;
import com.demomaster.quick_reader.constant.Constant;
import com.demomaster.quick_reader.util.BookManager;
import com.demomaster.quick_reader.util.FileUtils;
import com.demomaster.quick_reader.util.IOUtils;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.List;

import io.reactivex.Single;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;

/**
 * Created by newbiechen on 17-5-8.
 * 存储关于书籍内容的信息(CollBook(收藏书籍),BookChapter(书籍列表),ChapterInfo(书籍章节),BookRecord(记录))
 */

public interface BookRepository {

    //存储已收藏书籍
    void saveCollBookWithAsync(CollBookBean bean);
    /**
     * 异步存储。
     * 同时保存BookChapter
     * @param beans
     */
    void saveCollBooksWithAsync(List<CollBookBean> beans);

    void saveCollBook(CollBookBean bean);

    void saveCollBooks(List<CollBookBean> beans);

    /**
     * 异步存储BookChapter
     * @param beans
     */
    void saveBookChaptersWithAsync(List<BookChapterBean> beans);

    /**
     * 存储章节
     * @param folderName
     * @param fileName
     * @param content
     */
    void saveChapterInfo(String folderName,String fileName,String content);

    void saveBookRecord(BookRecordBean bean);

    /*****************************get************************************************/
    CollBookBean getCollBook(String bookId);
    List<CollBookBean> getCollBooks();

    //获取书籍列表
    Single<List<BookChapterBean>> getBookChaptersInRx(String bookId);

    //获取阅读记录
    BookRecordBean getBookRecord(String bookId);
    //TODO:需要进行获取编码并转换的问题
    ChapterInfoBean getChapterInfoBean(String folderName,String fileName);

    /************************************************************/

    /************************************************************/
    Single<Void> deleteCollBookInRx(CollBookBean bean);

    //这个需要用rx，进行删除
    void deleteBookChapter(String bookId);

    public void deleteCollBook(CollBookBean collBook);

    //删除书籍
    public void deleteBook(String bookId);

    public void deleteBookRecord(String id);

    //删除任务
    public void deleteDownloadTask(String bookId);

}
